import { useTable, LIST_TYPE } from '@crud/index';
import { getColonelAllList } from '@/api/crm-agency/kgj/colonel';
import { toolOptions2Map } from '@/utils';

// 查询
export const levelOptions = [
  { label: '初级', value: 1 },
  { label: '高级', value: 2 }
];
export const dyjLevelOptions = [
  { label: 'A级', value: 1 },
  { label: 'S级', value: 2 }
];
export const levelMap = toolOptions2Map(levelOptions);
export const dyjLevelMap = toolOptions2Map(dyjLevelOptions);
// 表格
export const useTableList = (options: any = {}) => {
  const columns: any= [
    { label: '代理名称', prop: 'name', minWidth: 160, fixed: 'left' },
    { label: '代理账号', prop: 'mobile', minWidth: 160 },
    { label: '考古加', prop: 'level_str', minWidth: 120, render: (s: any) => levelMap[s.row.level] || '-' },
    // { label: '大赢加', prop: 'dyj_level', minWidth: 120, render: (s: any) => dyjLevelMap[s.row.dyj_level] || '-' },
    { label: '加入时间', prop: 'add_time', minWidth: 160, type: 'date' },
    { label: '考古加保证金', prop: 'safty', minWidth: 160, align: 'center' },
    { label: '大赢加保证金', prop: 'dyj_safty', minWidth: 160, align: 'center' },
    { label: '操作', render: 'actions', width: 100, align: 'center', fixed: 'right' }
  ];

  return useTable({
    ...options,
    type: LIST_TYPE.AGENCY,
    params: {
      keyword: '',
      from_dt: undefined,
      to_dt: undefined
    },
    columns: columns,
    getParams: ({ _timeArr = [], ...params }) => {
      // 处理时间参数
      if (_timeArr?.length) {
        const [begin, end] = _timeArr;
        params.from_dt = begin;
        params.to_dt = end;
      }
      return params;
    },
    getList: getColonelAllList
  });
};
